package br.ufmg.dcc.simulesspl.fsm;


public class FSM {
	
	private AbstractState currentState;

	public AbstractState getCurrentState() {
		return currentState;
	}

	public void goTo(AbstractState state) {
		if(currentState != null) {
			finish();
		}
		
		currentState = state;
		currentState.start();
	}

	public void run() {
		currentState.run();
	}

	public void goToAndRun(AbstractState state) {
		goTo(state);
		run();
	}

	public void finish() {
		if(currentState != null) {
			currentState.finish();
		}
	}
	
}
